package com.ly.lypopupwindowdemo.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.ly.lypopupwindowdemo.R;
import com.ly.lypopupwindowdemo.exception.OnDrawingException;
import com.ly.lypopupwindowdemo.views.CirclePercentView;
import com.ly.lypopupwindowdemo.views.RingView;

public class CustomCircleViewActivity extends AppCompatActivity {
    private Button mButton;
    private CirclePercentView mCirclePercentView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_circle_view);

        mCirclePercentView = (CirclePercentView) findViewById(R.id.circleView);
        mButton = (Button) findViewById(R.id.button);
        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int n = (int) (Math.random() * 100);
                mCirclePercentView.setPercent(n);
            }
        });

        RingView ring = (RingView) findViewById(R.id.ring);
        ring.setColors(new int[]{Color.RED, Color.GREEN, Color.BLUE, Color.GRAY, Color.YELLOW});
        ring.setValues(new int[]{5, 12, 13, 11, 10});
        try {
            ring.startDraw();
        } catch (OnDrawingException e) {
            e.printStackTrace();
        }
    }
}
